home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-19 / l2c-19.exe / BOFFSET.LSP < prev    next >
Lisp/Scheme  |  1993-06-25  |  6KB  |  140 lines

  1. ; BOFFSET.LSP  Copyright 1992  Tony Tanzillo   All Rights Reserved
  2. ;
  3. ; ************************** Notice *********************************
  4. ;
  5. ; Permission to use, copy, modify, and distribute this software
  6. ; for any non-commerial, non-profit purpose and without fee is
  7. ; hereby granted, provided that the above copyright notice appears
  8. ; in all copies and that both that above copyright notice and this
  9. ; permission notice appear in all supporting documentation.
  10. ;
  11. ; THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED
  12. ; WARRANTY.  ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR
  13. ; PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.
  14. ;
  15. ; Inquiry regarding commercial licensing of this material is welcome.
  16. ; *******************************************************************
  17. ;
  18. ;                         BOFFSET.LSP
  19. ;
  20. ;                        Tony Tanzillo
  21. ;                 Design Automation Consulting
  22. ;                        (201)523-7944
  23. ;
  24. ;               (Implemented on August 20, 1992)
  25. ;
  26. ; Requires AutoCAD Release 12.
  27. ;
  28. ; BOFFSET.LSP adds the BOFFSET command to AutoCAD.  BOFFSET is a
  29. ; command that unions the functionality of BPOLY and OFFSET into
  30. ; a single, highly-intuitive operation.  Sorry, no fancy dialog
  31. ; boxes or similar bells/whistles.  BOFFSET doesn't mess around,
  32. ; it just gets right down to business.
  33. ;
  34. ; With BOFFSET, you can easily generate "offset boundries", using
  35. ; the same method that is used to generate BPOLY's.  BOFFSET uses
  36. ; a selected point to both define the boundry, and to specify the
  37. ; offset (either towards the internal point at a specified offset
  38. ; distance or Through the internal point, depending on whether you
  39. ; specify an offset distance, or "Through", just like the AutoCAD
  40. ; offset command).
  41. ;
  42. ; When you invoke BOFFSET, it acts just like the OFFSET command,
  43. ; and asks for an offset distance or "Through".  Then, after you
  44. ; specify this, you are prompted for multiple internal points,
  45. ; that define each offset boundry, and direct the offset copy of
  46. ; it toward the inside of same.
  47. ;
  48. ; BOFFSET also supports explicit boundry sets via noun/verb entity
  49. ; selection.  If PICKFIRST is enabled, and there are objects that
  50. ; are currently selected when BOFFSET is invoked, they will be used
  51. ; as the boundry set.  Otherwise, all visible entities will become
  52. ; the boundry set.
  53. ;
  54. ; An effective way to demonstrate just how useful BOFFSET is, in
  55. ; contrast to other techniques required to achieve similar results,
  56. ; is to use it to convert a single-line schematic floor plan into a
  57. ; double-line floor plan, by simply picking a point in each space.
  58. ;
  59. ; To do this, just draw a schematic floor plan, by sub-dividing a
  60. ; rectangle into several distinct spaces (no leaks, the ends of the
  61. ; lines that subdivide spaces should extend just slightly beyond the
  62. ; adjacent lines they form junctions with).
  63. ;
  64. ; Once you have this, invoke BOFFSET, and specify an offset distance
  65. ; equal to one-half of the desired wall thickness.  Then, just pick
  66. ; a point inside of each space, and BOFFSET will do the rest (well,
  67. ; okay, it won't do windows).
  68. ;
  69. ; NOTE: BOFFSET calls the ADS external subroutine C:BPOLY which is
  70. ; defined by ACADAPP.EXE, and requires ACADAPP.EXE to be loaded prior
  71. ; to execution. 
  72. ;
  73. ; Good luck!
  74.  
  75.    (defun boff_err (s)
  76.       (cond
  77.          (  (member s '(  "Function cancelled"
  78.                           "console break"
  79.                           "quit / exit abort"
  80.                        )))
  81.          (t (princ "\nError [BOFFSET]: ")
  82.             (princ s)))
  83.       (setq *error* olderr)
  84.       (command ".redrawall")
  85.       (princ)
  86.    )
  87.  
  88.    (defun c:boffset ( / boundry dist off-dist p msg bpset dblast olderr)
  89.       (setvar "cmdecho" 0)
  90.       (if (setq bpset (ssget "i"))
  91.           (princ "\nUsing current selection as boundry set."))
  92.       (setq olderr *error* *error* boff_err)
  93.       (setq off-dist (getvar "offsetdist"))
  94.       (setq msg
  95.          (strcat "\nOffset distance/"
  96.             (cond (  (> off-dist 0)
  97.                      (strcat "Through/<" (rtos off-dist)))
  98.                   (t "<Through"))
  99.             ">: "
  100.          )
  101.       )
  102.       (initget "Through")
  103.       (setq dist (getdist msg))
  104.       (setvar "offsetdist"
  105.          (cond
  106.             (  (not dist) off-dist)
  107.             (  (eq dist "Through") -1.0)
  108.             (t dist)))
  109.       (command ".undo" "g" ".point" "0,0")
  110.       (setq dblast (entdel (entlast)))
  111.       (setq msg (if (minusp (getvar "offsetdist"))
  112.                     "\nSelect internal through point/Undo/<Exit>: "
  113.                     "\nSelect internal point/Undo/<Exit>: "))
  114.  
  115.       (while (and (setq p (progn (initget "Exit Undo")
  116.                                  (getpoint msg)))
  117.                   (/= p "Exit"))
  118.          (cond
  119.  
  120.             (  (eq p "Undo")
  121.                (if (entnext dblast)
  122.                    (entdel (entlast))
  123.                    (princ "\nCommand completely undone.")))
  124.  
  125.             (  (setq boundry (c:bpoly p bpset))
  126.                (if (not bpset)
  127.                    (setq bpset (ssget "p")))
  128.                (command ".offset" "" (list boundry p) p "")
  129.                (entdel boundry))
  130.  
  131.             (t (princ (strcat "\nCan't generate a boundry from selected "
  132.                                "internal point and/or boundry set.")))))
  133.  
  134.       (command ".undo" "e" ".redrawall")
  135.       (setq *error* olderr)
  136.       (princ)
  137.    )
  138.  
  139. ; :::::::::::::::::::::::::: EOF BOFFSET.LSP ::::::::::::::::::::::::::::::
  140.